home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / FLTK-1.0.6 / src / fl_overlay.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-07  |  2.0 KB  |  67 lines

  1. //
  2. // "$Id: fl_overlay.cxx,v 1.4 1999/01/07 19:17:40 mike Exp $"
  3. //
  4. // Overlay support for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-1999 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems to "fltk-bugs@easysw.com".
  24. //
  25.  
  26. // Extremely limited "overlay" support.  You can use this to drag out
  27. // a rectangle in response to mouse events.  It is your responsibility
  28. // to erase the overlay before drawing anything that might intersect
  29. // it.
  30.  
  31. #include <FL/x.H>
  32. #include <FL/fl_draw.H>
  33.  
  34. static int px,py,pw,ph;
  35.  
  36. static void draw_current_rect() {
  37. #ifdef WIN32
  38.   int old = SetROP2(fl_gc, R2_NOT);
  39.   fl_rect(px, py, pw, ph);
  40.   SetROP2(fl_gc, old);
  41. #else
  42.   XSetFunction(fl_display, fl_gc, GXxor);
  43.   XSetForeground(fl_display, fl_gc, 0xffffffff);
  44.   XDrawRectangle(fl_display, fl_window, fl_gc, px, py, pw, ph);
  45.   XSetFunction(fl_display, fl_gc, GXcopy);
  46. #endif
  47. }
  48.  
  49. void fl_overlay_clear() {
  50.   if (pw > 0) {draw_current_rect(); pw = 0;}
  51. }
  52.  
  53. void fl_overlay_rect(int x, int y, int w, int h) {
  54.   if (w < 0) {x += w; w = -w;} else if (!w) w = 1;
  55.   if (h < 0) {y += h; h = -h;} else if (!h) h = 1;
  56.   if (pw > 0) {
  57.     if (x==px && y==py && w==pw && h==ph) return;
  58.     draw_current_rect();
  59.   }
  60.   px = x; py = y; pw = w; ph = h;
  61.   draw_current_rect();
  62. }
  63.  
  64. //
  65. // End of "$Id: fl_overlay.cxx,v 1.4 1999/01/07 19:17:40 mike Exp $".
  66. //
  67.